#include<bits/stdc++.h>
using namespace std;
int cnt , n , k;
void f(int a){
	if((a - k) % 2 != 0 || a <= k){
		cnt++;
		return;
	}
	f((a + k) / 2);
	f((a - k) / 2);
}
int main(){
	freopen("farm.in", "r", stdin);
	freopen("farm.out", "w", stdout);
	cin >> n >> k;
	f(n);
	cout << cnt << endl;
	return 0;
}